forum

home / developersection / forums / how to populate a list inside a dictionary?

How to populate a list inside a dictionary?

Anonymous User 3068 16-Dec-2013

I have a dictionary that needs to be populate with a list. The code below does not work. How would I fix it?

clientinfo.cs

public Dictionary<int, List<string>> Languages { get; set; }

main.cs

var ClientsData = new List<MapModel.ClientInfo> { }
   ClientsData.Add(new MapModel.ClientInfo { Id = IDCounterDoctors, Languages = new Dictionary<int, List<string>>()});
   ClientsData[0].Languages.Add(2376, ["english", "french"]); // issue is here

c# c# 
Updated on 16-Dec-2013

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By